-
Notifications
You must be signed in to change notification settings - Fork 236
docs(sp-truncated): updated sp-truncated pattern #5839
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
|
📚 Branch Preview🔍 Visual Regression Test ResultsWhen a visual regression test fails (or has previously failed while working on this branch), its results can be found in the following URLs:
Deployed to Azure Blob Storage: If the changes are expected, update the |
Tachometer resultsCurrently, no packages are changed by this PR... |
Pull Request Test Coverage Report for Build 18939955006Details
💛 - Coveralls |
|
Known issue: |
TarunAdobe
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. I only have a couple of questions/suggestions.
Also I noticed that the API tab for truncated is all empty and I wonder if that's an easy fix or should we address that separately?
Yes in our component generation template we are explicitly checking for public properties to show in the API tab. For me this is too restrictive. When there is no modifier, it infers as privacy-> undefined. We can change the logic to place everything which is not private. Let's take this in a separate PR. return member?.privacy !== 'private'; |
blunteshwar
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!!
nikkimk
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for adding so many examples. In doing so I was able to test this and uncover more questions and issues. Take a look at what I have uncovered and decide which observations should be filed as issues, and which issues should be noted as warnings in this documentation.
| <sp-truncated> | ||
| ThisIsAVeryLongWordWithoutAnySpacesThatShouldBeTruncated | ||
| </sp-truncated> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This example isn't working on the docs page as the tooltip does not show the entire content.
| <sp-truncated> | ||
| This is the inline content that gets truncated | ||
| <span slot="overflow"> | ||
| This custom overflow content will appear in the tooltip with any | ||
| additional information or formatting you need. | ||
| </span> | ||
| </sp-truncated> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I noticed in the examples that only This is the inline content that gets is displayed and in the tooltip This custom overflow content will appear in the tooltip with any additional information or formatting you need gets displayed, which means, neither the truncated text nor the tooltip show the word truncated (ironic).
Should everything before the overflow be displayed, i.e This is the inline content that gets truncated? Or is this working as designed?
If the latter is true, we should warn consumers that setting the overflow might cause some words to be neither visible in the truncated line nor the tooltip.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why would we even include content in an overflowed slot that isnt the actual text? im needing a use case to understand how and when this should be used in product. its feeling like a dark UX pattern.
|
|
||
| #### Custom success message | ||
|
|
||
| When text is copied to the clipboard, a custom success message can be displayed: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried copying the text, and while I got the success message, when I pasted I noticed the copy wasn't the full text.
I didn't realize that the act of clicking the div would copy the whole thing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
again this feels like a dark pattern, does this mean that anything wrapped in a truncated is keyboard navigable? how would this functionality work for now mouse users? what visual queue are we providing that its copyable?
| <div | ||
| style="width: 250px; border: 1px solid var(--spectrum-gray-300); padding: 8px; border-radius: 4px;" | ||
| > | ||
| <sp-truncated>[email protected]</sp-truncated> | ||
| </div> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be a field instead of a div? Field labels should only be used with interactive elements, such as form fields.
| <sp-truncated> | ||
| very.long.username.that.exceeds.the.available.width | ||
| </sp-truncated> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The tooltip here is also not displaying the full content.
| **Important accessibility note:** The click handler on the truncated text does not include keyboard event handlers (`/* eslint-disable lit-a11y/click-events-have-key-events */`). This is a known limitation. Users who rely on keyboard navigation will need to use the tooltip hover interaction to view the full content, but cannot copy it via keyboard alone. | ||
|
|
||
| #### Screen readers | ||
|
|
||
| Screen readers will announce the visible truncated text. When the tooltip appears on hover, screen readers will announce the full content if it differs from the visible text. | ||
|
|
||
| For custom overflow content, ensure that the slotted content is semantically meaningful and properly structured for screen readers. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Since the
sp-truncateddoes not receive keyboard focus, a keyboard user will never be able to tooltip hover. - Screenreader users--who are very often but not always keyboard users---will hear the full content without the tooltip.
- Not all keyboard users are screenreader users, so this is an accessibility bug.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is a very interesting thread in the a11y channel on slack specifically about truncation and how its actually an inaccessible pattern as a whole. we might want to bring this up in one of our team meetings
I believe we should require every property has a modifier instead of loosing the API table generation. we should be intentional about our properties |
caseyisonit
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
left comments
Yup! You got this right. I did update it in my last PR so it should be fine now (since this is up to date with main). Everything which is not private should be in the API table for now. |


Description
Comprehensive documentation rewrite for sp-truncated with full API reference, accessibility guidelines, usage patterns, and practical examples across multiple component contexts.
Added sp-truncated to bundle/elements.ts to ensure proper component registration and CSS rendering in documentation demo blocks.
Motivation and context
Related issue(s)
Screenshots (if appropriate)
Author's checklist
Reviewer's checklist
patch,minor, ormajorfeaturesManual review test cases
Descriptive Test Statement
Descriptive Test Statement
Device review